﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Globalization;

namespace BlueLotus7.Web
{
    public class StatusCalendarViewControl : CalendarViewControl
    {

        public bool WeekOnly
        {
            get;
            protected set;
        }

        public StatusCalendarViewControl(DayOfWeek firstdayOfWeek, DateTime date, bool weekOnly)
            : base(CalendarFunctionMode.EventSummary, firstdayOfWeek, date)
        {
            this.WeekOnly = weekOnly;
        }

        #region Private Methods

        private string GeneratePeriodItem(DateTime startTime, DateTime endTime, string color, string summary, int dayHeight, int layerCount)
        {
            StringBuilder content = new StringBuilder();

            if (string.IsNullOrWhiteSpace(color))
            {
                color = "#80FFFF";
            }

            if (string.IsNullOrWhiteSpace(summary))
            {
                summary = string.Empty;
            }

            summary = startTime.ToString(datetimeFormat) + " - " + endTime.ToString(datetimeFormat) + "\n" + summary;

            content.Append("<div class=\"calendar-period\" ");
            content.Append("title=\"" + HttpUtility.HtmlEncode(summary) + "\" ");
            content.Append("style=\"color:" + color.Trim() + "; margin-left: " + (5 * layerCount).ToString() + "px;z-index: " + ((layerCount + 1) * 5).ToString() + "\">");
            //Todo top/buttom
            content.Append("</div>");
            return content.ToString();
        }

        #endregion

    }
}